//
//  config.hpp
//  utilities
//
//  Created by Sam Jaffe on 2/4/15.
//  Copyright (c) 2015 Sam Jaffe. All rights reserved.
//

#pragma once

#include <vector>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <functional>

namespace options {
        
    class parameter_base;
    
    class description {
    public:
        description(const std::string &name, const std::vector<std::string> &types, const std::string& desc = "");
    public:
        std::string name;
        std::vector<std::string> argument_types;
        std::string desc;
    };
    
    struct options_base {
        virtual void usage(const std::string& main) const {}
    };
    
    class config {
    public:
        template <typename T>
        friend class parser;
        
        typedef std::unordered_map<std::string, options::parameter_base*> options_map;
    private:
        config();
        ~config();
        
        typename options_map::iterator find_option(const std::string& key);
        typename options_map::iterator no_option();
        
        void print_options() const;
        
        std::string mainprog;
        std::string *end_of_args;
        std::vector<std::string> main_args;
        std::vector<options::parameter_base*> parsers;
        std::set<options::parameter_base*> required_arguments;
        std::map<std::string, options::description> usage_info;
        options_map parameter_mapping;
        unsigned short cols = 80;
        unsigned short lines = 24;
        bool die_on_illegal = true;
    };
    
}
